<template>
  <div>
    <div class="topheader" v-if="singlist">
      <div class="imgsinger">
        <img :src="singlist.artist.cover" alt="" />
      </div>
      <div class="title">
        {{ singlist.artist.name }}
      </div>
      <div class="button" @click="$router.push('/singer')">
        <span class="iconfont icon-zuoyoujiantou"></span>
        {{ singlist.artist.name }}
      </div>
      <span class="iconfont icon-fenxiang"></span>
    </div>

    <dl class="musicList">
      <dt>
        <i class="iconfont icon-sanjiaoxing"></i>播放全部<span
          >(共{{ songlist.songs.length }}首)</span
        >
      </dt>
      <dd
        v-for="(item, index) in songlist.songs"
        :key="item.id"
        @click="setId(item.id)"
      >
        <h1>{{ index + 1 }}</h1>
        <div class="info">
          <h2>{{ item.name }}</h2>
          <h3>
            <span v-for="value in item.ar" :key="value.id"
              >{{ value.name }}&nbsp;</span
            >
          </h3>
        </div>
      </dd>
    </dl>
    <!-- 底部组件 -->
    <bottom-nav></bottom-nav>
  </div>
</template>

<script>
import { getArtistDetail, getArtistTopSong } from "../../api/singer";
import bottomNav from "../base/bottomNav.vue";
export default {
  props: ["valueId"],
  data() {
    return {
      singlist: null,
      songlist: {
        songs: "",
      },
    };
  },
  methods: {
    getArtistDetailFun() {
      getArtistDetail({ id: this.$route.query.id }).then((data) => {
        console.log(data.data);
        this.singlist = data.data;
        console.log(this.$route.query);
      });
    },
    getArtistTopSongFun() {
      getArtistTopSong({ id: this.$route.query.id }).then((data) => {
        console.log(data.songs);
        console.log(data);
        this.songlist = data;
      });
    },
    setId(id) {
      // this.$emit("get-play-all-id",this.$route.query.id);//传递歌单id
      this.$emit("get-player-id", id);
    },
  },
  created() {
    this.getArtistDetailFun();
    this.getArtistTopSongFun();
  },
  components: {
    bottomNav,
  },
};
</script>

<style lang="less">
.topheader {
  position: relative;
  height: 270px;
  .icon-fenxiang {
    font-size: 23px;
    position: absolute;
    top: 12px;
    right: 20px;
    color: white;
  }
  .imgsinger {
    // background-color: aqua;
    width: 100%;
    height: 270px;
    position: relative;
    img {
      position: absolute;
      top: 0px;
      left: 0px;
      right: 0px;
      bottom: 0px;
      margin: auto;
      width: 100%;
    }
  }
  .title {
    font-size: 18px;
    position: absolute;
    left: 18px;
    bottom: 18px;
    color: #fff;
  }
  .button {
    font-size: 18px;
    position: absolute;
    left: 12px;
    top: 12px;
    color: #fff;
  }
}
.musicList {
  background-color: #fff;
  width: 100%;
  border-radius: 7px;
  position: relative;
  top: -7px;
  padding-bottom: 50px;
  dt {
    height: 36px;
    line-height: 36px;
    font-size: 16px;
    color: #454747;
    border-bottom: 1px solid #e3e3e3;
    span {
      font-size: 14px;
      color: #797b7a;
    }
    i {
      width: 44px;
      text-align: center;
      display: inline-block;
    }
  }
  dd {
    border-bottom: 1px solid #e3e3e3;
    height: 53px;
    display: flex;
    h1 {
      flex: 0 0 44px;
      line-height: 53px;
      text-align: center;
      font-size: 16px;
      color: #6d6e6e;
    }
    .info {
      flex: 1;
      h2 {
        font-size: 16px;
        color: #1b1c1c;
        margin-top: 10px;
      }
      h3 {
        font-size: 12px;
        color: #929393;
      }
    }
  }
}
</style>